/**
 ******************************************************************************
 * @file           : ds3553.h
 * @brief          : Header for ds3553.c file.
 ******************************************************************************
 * @attention
 ******************************************************************************
 */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __DS3553_H
#define __DS3553_H
/* Private includes ----------------------------------------------------------*/
#include "stm32f1xx_hal.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/**
 * 芯片I2C通讯地址
 */
#define DS3553_I2C_ADDR 0x27
#define DS3553_I2C_ADDR_R ((DS3553_I2C_ADDR << 1) | 0x01)
#define DS3553_I2C_ADDR_W (DS3553_I2C_ADDR << 1)

/**
 * 芯片寄存器地址
 */
#define DS3553_CHIP_ID 0x01
#define DS3553_USER_SET 0xC3
#define DS3553_STEP_CNT_L 0xC4
#define DS3553_STEP_CNT_M 0xC5
#define DS3553_STEP_CNT_H 0xC6

/**
 * USER_SET寄存器的位定义
 */
#define USER_SET_PEDO_POS (0U)
#define USER_SET_PEDO_MSK (0x3UL << USER_SET_PEDO_POS)
#define USER_SET_PEDO USER_SET_PEDO_MSK /* pedo[1:0]字段；00：手环算法（默认）01：计步鞋算法 10：计步器算法 */
#define USER_SET_PEDO_0 (0x1UL << USER_SET_PEDO_POS)
#define USER_SET_PEDO_1 (0x2UL << USER_SET_PEDO_POS)

#define USER_SET_CLEAR_POS (2U)
#define USER_SET_CLEAR_MSK (0x1UL << USER_SET_CLEAR_POS)
#define USER_SET_CLEAR USER_SET_CLEAR_MSK /* clear位；0：步数不清零（默认）1：步数清零 */

#define USER_SET_NOISE_DIS_POS (3U)
#define USER_SET_NOISE_DIS_MSK (0x1UL << USER_SET_NOISE_DIS_POS)
#define USER_SET_NOISE_DIS USER_SET_NOISE_DIS_MSK /* noise_dis位；0：禁止去噪功能 1：使能去噪功能，
当 sen_dis = 0，10 步开始计步；当 sen_dis = 1，15 步开始计步（默认，仅为手环和计步器使用） */

#define USER_SET_PULSE_EN_POS (4U)
#define USER_SET_PULSE_EN_MSK (0x1UL << USER_SET_PULSE_EN_POS)
#define USER_SET_PULSE_EN USER_SET_PULSE_EN_MSK /* pulse_en位；0：禁止计步脉冲输出 1：使能计步脉冲输出（默认） */

#define USER_SET_RAISE_EN_POS (5U)
#define USER_SET_RAISE_EN_MSK (0x1UL << USER_SET_RAISE_EN_POS)
#define USER_SET_RAISE_EN USER_SET_RAISE_EN_MSK /* raise_en位；0：禁止抬手脉冲输出（默认）1：使能抬手脉冲输出（仅为手环使用） */

#define USER_SET_SEN_DIS_POS (6U)
#define USER_SET_SEN_DIS_MSK (0x1UL << USER_SET_SEN_DIS_POS)
#define USER_SET_SEN_DIS USER_SET_SEN_DIS_MSK /* sen_dis位；0：正常计步灵敏度（默认）1：降低计步灵敏度 */

#define USER_SET_PWR_MODE_POS (7U)
#define USER_SET_PWR_MODE_MSK (0x1UL << USER_SET_PWR_MODE_POS)
#define USER_SET_PWR_MODE USER_SET_PWR_MODE_MSK /* pwr_mod位；0：正常模式（默认）1：待机模式 */

/* Exported functions prototypes ---------------------------------------------*/
void DS3553_WriteReg(uint8_t regAddr, uint8_t data);
uint8_t DS3553_ReadReg(uint8_t regAddr);
void DS3553_Init(void);
uint32_t DS3553_readStepCount(void);
/* Private defines -----------------------------------------------------------*/

#endif /* __DS3553_H */
